/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package upc.jfactory.scp.bl.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import upc.jfactory.scp.entidad.Rol;
import upc.jfactory.srp.services.export.Exception_Exception;
import upc.jfactory.srp.services.export.RolBean;
import upc.jfactory.srp.services.export.ServicioRoles;
import upc.jfactory.srp.services.export.ServicioRolesService;

/**
 *
 * @author Diego
 */
public class RolController {
 public RolController(){}
 public List<Rol> selectRoles(){
      Rol rol;
       List<Rol> lsRol = new ArrayList<Rol>();
        try { // Call Web Service Operation
          ServicioRolesService servicio = new ServicioRolesService();
              ServicioRoles port = servicio.getServicioRolesPort();

               List<RolBean> result = new ArrayList<RolBean>();
              result=port.getRoles();

              for(int i=0; i<result.size();i++)
              {
                rol = new Rol();
                rol.setNombreRol(result.get(i).getNombre());
                rol.setIdRol(result.get(i).getRolId());
                lsRol.add(rol);

              }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return lsRol;
    }
 public String NombreRol(int id){
        try {
            ServicioRolesService servicio = new ServicioRolesService();
            ServicioRoles port = servicio.getServicioRolesPort();
            return port.getRolxId(id);
        } catch (Exception_Exception ex) {
            Logger.getLogger(RolController.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
 }

 }

